﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RepositoryFramework;

namespace Portal.Repository
{
	/// <summary>
	/// Class <see cref="PortalUnitOfWorkProvider"/> define portal unit of work provider
	/// </summary>
	public class PortalUnitOfWorkProvider : UnitOfWorkProvider<IPortalUnitOfWork>, IPortalUnitOfWorkProvider
	{
		#region Fields
		private readonly string _connectionString;
		#endregion

		#region .ctor
		/// <summary>
		/// Initializes a new instance of the <see cref="UserRepository"/> class.
		/// </summary>
		/// <param name="connectionString">The connection string.</param>
		/// <exception cref="System.ArgumentException">connectionString</exception>
		public PortalUnitOfWorkProvider(string connectionString)
		{
			if (string.IsNullOrWhiteSpace(connectionString))
			{
				throw new ArgumentException("connectionString");
			}
			_connectionString = connectionString;
		}
		#endregion

		#region Methods

		/// <summary>
		/// Gets the new unit of work.
		/// </summary>
		/// <returns></returns>
		protected override IPortalUnitOfWork GetNew()
		{
			return new PortalUnitOfWork(_connectionString);
		}

		#endregion
	}
}
